package com.wecheir.dao;

import com.wecheir.entity.Role;
import com.wecheir.entity.User;
import com.wecheir.entity.UserRegister;
import com.wecheir.utils.ResponseUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Repository
public interface UserDao {


    public List<UserRegister> findUserByLoginName(String loginName);

    public User selectUserByTellOrEmail(@Param("tel")String tel, @Param("email")String email);

    /**
     * 登录方法
     * @return
     */
    public boolean login(String acc,String pwd);

    public boolean userRegister(UserRegister user);

    /**
     * 更新用户的信誉度
     * @param user
     */
    void updateUserOnlyCredit(User user);

    User selectUserByUser(User user);

    User selectUserByMap(Map<String,Object> map);

    void saveUserRoles(@Param("userId")String id, @Param("roleIds") Set<Role> roles);

    void dropUserRolesByUserId(@Param("userId")String id);

//    void insertUserRegist(UserRegist user);

    List<User> findAllUser();


    /**
     * 根据当前用户id,查找农田主id,判断当前人员是农田主还是农田管理员,有返回农田主id说明是农田管理员,没有说明当前用户是农田主
     * @param id
     * @return
     */
    String findFarmOwnManagerIdById(String id);

    /**
     * 获得所有拥有农田管理员身份的用户
     * @return
     */
    List<User> getAllHaveManagerIdentityUser();
    /**
     * 重置用户信誉度
     * @param user
     * @return
     */
    int resetCredit(User user);

    User findUserById(String id);

    boolean updateLoginNameById(@Param("id")String id, @Param("loginName")String loginName);

    boolean updateNickNameById(@Param("id")String id,@Param("nickName") String nickName);

    boolean updateRemarksById(@Param("id")String id,@Param("remarks") String remarks);

    boolean updateIconById(@Param("id")String id,@Param("path") String path);

    User findUserByName(String userName);

    void updatePwd(String userName,String newPwd);
}
